package com.by.wx.service.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.by.common.vo.PhoneRoomResult;
import com.by.wx.dao.PhoneDao;
import com.by.wx.entity.PhoneCode;
import com.by.wx.entity.PhoneMember;
import com.by.wx.service.PhoneService;

//ok
@Service
public class PhoneServiceImpl implements PhoneService {

	public static Log log = LogFactory.getLog(PhoneServiceImpl.class);

	@Autowired
	private PhoneDao phoneDao;

	@Override
	public int saveCode(String phone, String rod) {
		if (StringUtils.isEmpty(phone))
			throw new RuntimeException("手机号码不能为空");
		if (StringUtils.isEmpty(rod))
			throw new RuntimeException("手机验证码不能为空");

		PhoneCode pco = new PhoneCode();
		pco.setPhone(phone);
		pco.setCode(rod);
		return phoneDao.saveCode(pco);
	}

	@Override
	public List<PhoneCode> dofind(String phone) {
		return phoneDao.dofind(phone);
	}

	@Override
	public List<PhoneRoomResult> findRoomrecordByMemberPhone(String phone) {
		return phoneDao.findRoomrecordByMemberPhone(phone);
	}

	@Override
	public List<PhoneMember> verifyPhoneCheck(String phone) {
		return phoneDao.verifyPhoneCheck(phone);
	}

	@Override
	public List<PhoneMember> doFindMemInfoByPhone(String phone) {
		return phoneDao.doFindMemInfoByPhone(phone);
	}

}
